package com.linewell.system.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @MethodName : toJson
 * @Description : 将对象转为JSON串，此方法能够满足大部分需求
 * @param bean :将要被转化的对象
 * @return value :转化后的JSON串
 */
public class JsonUtil {
	private static ObjectMapper m = new ObjectMapper();

	public static String toJson(Object bean) {
		if(bean != null){
			String value = null;
			try {
				value = m.writeValueAsString(bean);
			} catch (JsonProcessingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return value;
		}
		return null;
		
	}
}
